<?
if(! defined('BASEPATH') ){ exit('Unable to view file.'); }

$sql = $db->Query("SELECT * FROM `sites` WHERE `id`='".$id."' AND `user`='".$data['login']."'");
$data2 = $db->FetchArray($sql);

$maxcpc = ($data['premium'] > 0 ? 10 : 5);

if(isset($_POST['edit']) && $data2['id'] != "" && $_POST['cpc'] > 0 && $_POST['cpc'] <= $maxcpc){
	$title = $db->EscapeString($_POST['title']);
	$cpc = $db->EscapeString($_POST['cpc']);
	$status = $db->EscapeString($_POST['status']);
	
	$db->Query("UPDATE `sites` SET `title`='".$title."', `cpc`='".$cpc."', `banned`='".$status."' WHERE `id`='".$data2['id']."'");
	echo '<div class="msg"><div class="success">Site successfully changed!</div></div>';
}
?>
<form method="post" action="">
<fieldset>
    <p>
		<label>Site URL</label><br/>
		<input class="text big" type="text" value="<?=$data2['site']?>" name="url" disabled />
	</p>
	<p>
		<label>Title</label><br/>
		<input class="text big" type="text" value="<?=$data2['title']?>" name="title" maxlength="15" />
	</p>
	<p>
		<label>CPC</label> <br/>
        <select class="styled" name="cpc">
		    <option value="1">1 Coin</option>
			<option value="2"<?if($data2['cpc'] == 2){?> selected<?}?>>2 Coins</option>
			<option value="3"<?if($data2['cpc'] == 3){?> selected<?}?>>3 Coins</option>
			<option value="4"<?if($data2['cpc'] == 4){?> selected<?}?>>4 Coins</option>
			<option value="5"<?if($data2['cpc'] == 5){?> selected<?}?>>5 Coins</option><?if($data['premium'] > 0){?>
			<option value="6"<?if($data2['cpc'] == 6){?> selected<?}?>>6 Coins</option>
			<option value="7"<?if($data2['cpc'] == 7){?> selected<?}?>>7 Coins</option>
			<option value="8"<?if($data2['cpc'] == 8){?> selected<?}?>>8 Coins</option>
			<option value="9"<?if($data2['cpc'] == 9){?> selected<?}?>>9 Coins</option>
			<option value="10"<?if($data2['cpc'] == 10){?> selected<?}?>>10 Coins</option><?}?>
		</select>
	</p>
	<p>
		<label>Status</label> <br/>
        <select class="styled" name="status">
		    <option value="0">Active</option>
			<option value="1"<?if($data2['banned'] == 1){?> selected<?}?>>Inactive</option>
		</select>
	</p>
    <p style="text-align: center; padding-top: 15px;">
		<input type="submit" class="gbutton" value="Edit" name="edit" />
	</p>
</fieldset>
</form><br>
<div class="msg"><div class="info"><a href="mysites.php" style="color:blue"><b>Back to sites!</b></a></div></div>